package lanqiao;

import java.util.Scanner;

public class 外卖店优先级 {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        int T = scanner.nextInt();

        int[][] arr = new int[T+1][N+1];

        for (int i = 0; i < M ; i++) {
            int time = scanner.nextInt();
            int shop = scanner.nextInt();
            arr[time][shop]++;
        }
        int cur = 0;
        for (int i = 1; i < N+1; i++) {
            int end = 0;
            for (int j = 0; j <T+1; j++) {
                if (arr[j][i]!=0){
                    end += arr[j][i]*2;
                }else if (end>0){
                    end--;
                }
            }
            if (end>5){
                cur++;
            }
        }
        System.out.println(cur);
    }
}
